package com.pengliu;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.pengliu.config.SysEnv;
import com.pengliu.dll.Ocr_dll;

@SpringBootApplication
@ServletComponentScan("com.pengliu")
@EnableAutoConfiguration(exclude = {MultipartAutoConfiguration.class})
@MapperScan("com.pengliu.dao")
@ComponentScan("com.pengliu")
@EnableTransactionManagement(proxyTargetClass = true)
public class Application implements CommandLineRunner{
	
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    /**
     *	<p>函数名称: run()</p>
     *	<p>公司: 卡萨维斯</p>
     *	<p>方法描述: 项目启动后执行</p>
     *	<p>方法调用例子：</p>
     *	<p>完成日期：2017年9月15日 下午3:04:57</p>
     *	@param args
     *	@throws Exception
     *	@author  彭柳
     *	@version 1.0
     */
	public void run(String... args) throws Exception {
		String active = SysEnv.active;
		String port = SysEnv.port;
		String contextPath = SysEnv.contextPath;
		System.out.println("**********************************************");
		if("dev".equalsIgnoreCase(active)) {
			System.out.println("【开发环境】");
		}else if("test".equalsIgnoreCase(active)) {
			System.out.println("【测试环境】");
		}else {
			System.out.println("【正式环境】");
		}
		System.out.println("**********************************************");
		System.err.println( "[INFO] 程序运行服务地址   http://localhost:"+port+contextPath );
		
//		WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();    
//      ServletContext servletContext = webApplicationContext.getServletContext();
//      servletContext.setAttribute("baseHome", SysConfig.getProperty("baseHome"));
	}

}
